/*搜索*/
// document.getElementById('searchBtn').onclick = function() {
//     var userName = document.getElementById('userName').value;
//     var age = document.getElementById('age').value;
//     console.log(userName, age);
//     // mui.ajax('/admin/search',{
//     //     data:{
//     //         userName: userName,
//     //         age: age
//     //     },
//     //     type:'post',//HTTP请求类型
//     //     success:function(data){
//     //         console.log(data);
//     //     },
//     //     error:function(data){
//     //         console.log('data',data);
//     //     }
//     // });
// }
var id;
/*编辑*/
var btns = document.getElementsByClassName("mui-bg-primary");
for(var i = 0; i < btns.length; i++) {
    btns[i].onclick = function() {
        document.getElementById('dialog').style.display = 'block';
        id = this.getAttribute('data-id');
        console.log(id);
        mui.ajax('/admin/info',{
            data:{
                id: id
            },
            type:'post',//HTTP请求类型
            success:function(data){
                document.getElementById('id').value=data.id;
                document.getElementById('shopName').value=data.mallName;
                document.getElementById('address').value=data.mallAddress;
                document.getElementById('tel').value=data.mallMobile;
                document.getElementById('totalCount').value=data.totalNum;
                document.getElementById('latitude').value=data.latitude;
                document.getElementById('longitude').value=data.longitude;
                document.getElementById('imageUrl').value=data.imageurl;
                document.getElementById('remark').value=data.remark;
                console.log(data);
            },
            error:function(data){
                console.log('data',data);
            }
        });
    }
}
/*取消*/
document.getElementById('cancel').onclick = function() {
    document.getElementById('dialog').style.display = 'none';
}
/*保存*/
document.getElementById('makesure').onclick = function() {
    var pcId = document.getElementById('id').value;
    var mallName = document.getElementById('shopName').value;
    var mallAddress = document.getElementById('address').value;
    var mallMobile = document.getElementById('tel').value;
    var totalNum = document.getElementById('totalCount').value;
    var latitude = document.getElementById('latitude').value;
    var longitude = document.getElementById('longitude').value;
    var imageUrl = document.getElementById('imageUrl').value;
    var remark = document.getElementById('remark').value;
    mui.ajax('/admin/pc/update',{
        data:{
            id: pcId,
            mallName: mallName,
            mallAddress: mallAddress,
            mallMobile: mallMobile,
            totalCount: totalNum,
            totalNum: totalNum,
            latitude: parseFloat(latitude),
            longitude: parseFloat(longitude),
            imageurl:imageUrl,
            remark:remark
        },
        type:'post',//HTTP请求类型
        success:function(data){
           location.href="/admin/pc/list"
        },
        error:function(data){
            console.log('data',data);
        }
    });
}
/*登出*/
// document.getElementById('logout').onclick = function () {
//     location.href = "/admin/pc/loginOut";
// }

document.getElementById('addMall').onclick=function () {
    document.getElementById('id').value='';
    document.getElementById('shopName').value='';
    document.getElementById('address').value='';
    document.getElementById('tel').value='';
    document.getElementById('totalCount').value='';
    document.getElementById('latitude').value='';
    document.getElementById('longitude').value='';
    document.getElementById('imageUrl').value='';
    document.getElementById('remark').value='';
    document.getElementById('dialog').style.display = 'block';
}